|
|||||||||||||||||||
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover | |||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
ModuleFactory.java | 71.4% | 73.7% | 100% | 74.3% |
|
1 |
/*
|
|
2 |
* Copyright 2001-2004 The Apache Software Foundation.
|
|
3 |
*
|
|
4 |
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5 |
* you may not use this file except in compliance with the License.
|
|
6 |
* You may obtain a copy of the License at
|
|
7 |
*
|
|
8 |
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9 |
*
|
|
10 |
* Unless required by applicable law or agreed to in writing, software
|
|
11 |
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13 |
* See the License for the specific language governing permissions and
|
|
14 |
* limitations under the License.
|
|
15 |
*/
|
|
16 |
|
|
17 |
package org.apache.geronimo.ews.ws4j2ee.module;
|
|
18 |
|
|
19 |
import org.apache.geronimo.ews.ws4j2ee.toWs.GenerationFault;
|
|
20 |
import org.apache.geronimo.ews.ws4j2ee.toWs.UnrecoverableGenerationFault;
|
|
21 |
|
|
22 |
import java.io.File;
|
|
23 |
|
|
24 |
/**
|
|
25 |
* @author Srinath Perera(hemapani@opensource.lk)
|
|
26 |
*/
|
|
27 |
public class ModuleFactory { |
|
28 |
|
|
29 |
/**
|
|
30 |
* @param path - path to the package
|
|
31 |
* @param firstmodule - is it the first module or a module inside other module
|
|
32 |
* @return
|
|
33 |
* @throws GenerationFault
|
|
34 |
*/
|
|
35 | 15 |
public static Module createPackageModule(String path,File outDir) throws UnrecoverableGenerationFault { |
36 | 15 |
return createPackageModule(path, Thread.currentThread().getContextClassLoader(),outDir);
|
37 |
} |
|
38 |
|
|
39 | 15 |
public static Module createPackageModule(String path, |
40 |
ClassLoader parentCL,File outDir) throws UnrecoverableGenerationFault {
|
|
41 | 15 |
try {
|
42 | 15 |
if (path != null) { |
43 | 15 |
File file = new File(path);
|
44 | 15 |
if (!file.exists())
|
45 | 0 |
throw new UnrecoverableGenerationFault("file not found " + file.getAbsolutePath()); |
46 | 15 |
if (file.isDirectory()) {
|
47 | 0 |
return new DirModule(path, parentCL); |
48 | 15 |
} else if (path.endsWith(".jar") || path.endsWith(".JAR")) |
49 | 7 |
return new JarModule(path, parentCL); |
50 | 8 |
else if (path.endsWith(".war") || path.endsWith(".WAR")) |
51 | 3 |
return new WARModule(path, parentCL,outDir); |
52 | 5 |
else if (path.endsWith(".ear") || path.endsWith(".EAR")) |
53 | 2 |
return new EARModule(path,outDir); |
54 | 3 |
else if (path.endsWith(".xml")) |
55 | 3 |
return new DirModule(new File(path)); |
56 |
else
|
|
57 | 0 |
throw new UnrecoverableGenerationFault("unknown type of file"); |
58 |
} |
|
59 |
} catch (GenerationFault e) {
|
|
60 | 0 |
throw new UnrecoverableGenerationFault(path + " not found ", e); |
61 |
} |
|
62 | 0 |
throw new UnrecoverableGenerationFault("path is null"); |
63 |
} |
|
64 |
} |
|
65 |
|
|